from flask import Flask
from flask_restful import Api,Resource,fields,marshal_with
app=Flask(__name__)
api=Api(app)
class New:
    def __init__(self,code,msg,state,content):
        self.code=code
        self.msg=msg
        self.state=state
        self.content=content

class NewView(Resource):
    re_fi={
        "code":fields.Integer,
        "msg":fields.String,
        "state":fields.String
    }
    @marshal_with(re_fi)
    def get(self):
        return {"code":200,"msg":"访问成功","state":"移动"}
    @marshal_with(re_fi)
    def post(self):
        return {"msg":"注册成功"}
    @marshal_with(re_fi)
    def put(self):
        new=New(404,"Ok","电脑端","sh")
        return new

api.add_resource(NewView,"/new/")

if __name__=="__main__":
    app.run(debug=True)
